[FIX] purchase_request: handle move_dest_ids as False in Odoo 18#3019
Open
[FIX] purchase_request: handle move_dest_ids as False in Odoo 18#3019
Conversation
In Odoo 18, procurement.values.get('move_dest_ids') can return False
(boolean) instead of an empty list when no destination moves exist.
The previous code used get('move_dest_ids', []) which only uses the
default when the key doesn't exist, not when it's explicitly False.
This causes: TypeError: 'bool' object is not iterable
Fix: use 'or []' to ensure we always have an iterable list.
Closes: OCA#2927
There was a problem hiding this comment.
Pull request overview
Fixes an Odoo 18 compatibility issue in purchase_request where procurement.values.get("move_dest_ids") may be False (not iterable), causing a TypeError during purchase request line preparation.
Changes:
- Make
_prepare_purchase_request_linerobust tomove_dest_ids=Falseby falling back to an empty iterable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add test for issue OCA#2927 to ensure procurement works when move_dest_ids is False/None, which can happen in Odoo 18. This test prevents regression of TypeError: 'bool' object is not iterable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In Odoo 18,
procurement.values.get('move_dest_ids')can returnFalse(boolean) instead of an empty list when no destination moves exist.The previous code used
get('move_dest_ids', [])which only uses the default when the key doesn't exist, not when it's explicitlyFalse.This causes:
TypeError: 'bool' object is not iterableFix
Changed line 25 in
purchase_request/models/stock_rule.pyfrom:to:
This ensures we always have an iterable list.
Related Issue
Closes #2927
I am a contributor from the SMWLAB community and this is my first OCA PR. Please review!